using DataDynamics.ActiveReports;
using DataDynamics.ActiveReports.Export.Xls;
using SM.core;
using SS;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
namespace TVSBH.func
{
	public class frmUnderBalancer : Form
	{
		private Func objFunc = new Func();
		private DataTable objTable = new DataTable();
		private Bill objBill = new Bill();
		private int DayBalancer = 0;
		private bool IsPostBack = false;
		private string strConnection = "";
		private string currWhID = "";
		public string userName = "";
		public string fullName = "";
		private IContainer components = null;
		private DataGridView dgvProduct;
		private Button btnClose;
		private GroupBox groupBox1;
		private ComboBox cbbParentGID;
		private System.Windows.Forms.Label label1;
		private Button btnPrint;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox txtNumber;
		private System.Windows.Forms.CheckBox cbbDayDefault;
		private DataGridViewTextBoxColumn Column2;
		private DataGridViewTextBoxColumn Column1;
		private DataGridViewTextBoxColumn Column6;
		private DataGridViewTextBoxColumn Column4;
		private DataGridViewTextBoxColumn Column3;
		private DataGridViewTextBoxColumn Column9;
		private System.Windows.Forms.Label lblWarning;
		private System.Windows.Forms.TextBox txtSearch;
		private System.Windows.Forms.Label label2;
		private Button btnExportToExcel;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
		public frmUnderBalancer()
		{
			this.InitializeComponent();
		}
		private void frmInput_Load(object sender, EventArgs e)
		{
			this.currWhID = this.objFunc.getWarehouse(this.userName);
			Program.strConnectionString = this.objFunc.strConnectionString;
			this.DayBalancer = this.objFunc.getWarningNumberProduct();
			this.txtNumber.Text = this.DayBalancer.ToString();
			this.objFunc.LoadComboBoxGProduct("SELECT [GpID], UPPER([GpName]) AS GpName FROM [TabGproducts] ORDER BY [GpName]", this.cbbParentGID, "GpID", "GpName");
			this.dgvProduct.AutoGenerateColumns = false;
			this.IsPostBack = true;
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void frmInput_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}
		private void cbbParentGID_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (this.cbbParentGID.SelectedValue.ToString() != "0")
			{
				this.getDetailBalancer("SELECT * FROM [TabTotalBalancer] WHERE [Pid] IN (SELECT [Pid] FROM [TabProducts] WHERE [GpID] = " + this.cbbParentGID.SelectedValue.ToString() + ") ORDER BY [ProductName]");
			}
			else
			{
				this.getDetailBalancer("");
			}
		}
		public void getDetailBalancer(string sqlQuery)
		{
			try
			{
				DataTable dataTable = new DataTable();
				DataColumn column = new DataColumn("Pid", typeof(string));
				DataColumn column2 = new DataColumn("ProductName", typeof(string));
				DataColumn column3 = new DataColumn("ProductNumberMin", typeof(string));
				DataColumn column4 = new DataColumn("ProductNumberBalancer", typeof(string));
				DataColumn column5 = new DataColumn("ProductNumberMax", typeof(string));
				DataColumn column6 = new DataColumn("ProductUnit", typeof(string));
				dataTable.Columns.Add(column);
				dataTable.Columns.Add(column2);
				dataTable.Columns.Add(column3);
				dataTable.Columns.Add(column4);
				dataTable.Columns.Add(column5);
				dataTable.Columns.Add(column6);
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				if (sqlQuery == "")
				{
					this.DayBalancer = int.Parse(this.txtNumber.Text);
					sqlCommand.CommandText = "SELECT * FROM [TabTotalBalancer] ORDER BY [ProductName]";
				}
				else
				{
					sqlCommand.CommandText = sqlQuery;
				}
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				while (sqlDataReader.Read())
				{
					string sqlQuery2 = "SELECT (SUM([ProductNumberIn]) - SUM([ProductNumberOut])) AS totalBalancer FROM [TabTotalBalancer] WHERE [PID] = " + sqlDataReader["PID"].ToString();
					float num = float.Parse(this.numTotalBalancerOfProduct(sqlQuery2));
					float num2 = float.Parse(sqlDataReader["MinBalance"].ToString());
					float num3 = float.Parse(sqlDataReader["MaxBalance"].ToString());
					if (num - num2 <= float.Parse(this.txtNumber.Text))
					{
						if (!this.checkProductNameInDataGridView(sqlDataReader["ProductName"].ToString(), dataTable))
						{
							dataTable.Rows.Add(new object[]
							{
								sqlDataReader["Pid"].ToString(),
								sqlDataReader["ProductName"].ToString(),
								num2.ToString(),
								num.ToString(),
								num3.ToString(),
								" " + sqlDataReader["ProductUnit"].ToString()
							});
						}
					}
				}
				sqlDataReader.Close();
				sqlConnection.Close();
				sqlConnection.Dispose();
				this.btnPrint.Enabled = true;
				this.objTable = dataTable;
				this.dgvProduct.DataSource = this.objTable;
				if (this.objTable.Rows.Count > 0)
				{
					this.lblWarning.Text = string.Concat(new string[]
					{
						"CÓ ",
						this.dgvProduct.Rows.Count.ToString(),
						" SẢN PHẨM CÓ SỐ LƯỢNG TỒN TRÊN MỨC TỐI THIỂU DƯỚI ",
						this.txtNumber.Text.ToUpper(),
						" SẢN PHẨM"
					});
					this.btnPrint.Enabled = true;
					this.btnExportToExcel.Enabled = true;
				}
				else
				{
					this.btnPrint.Enabled = false;
					this.btnExportToExcel.Enabled = false;
				}
			}
			catch
			{
				this.btnPrint.Enabled = false;
				this.btnExportToExcel.Enabled = false;
				this.objTable = null;
				this.dgvProduct.DataSource = this.objTable;
			}
		}
		private string numTotalBalancerOfProduct(string sqlQuery)
		{
			string text = "0";
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = sqlConnection.CreateCommand();
			sqlCommand.CommandText = sqlQuery;
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					text = sqlDataReader["totalBalancer"].ToString();
				}
			}
			else
			{
				text = "0";
			}
			sqlDataReader.Close();
			sqlConnection.Close();
			sqlConnection.Dispose();
			if (text.Trim() == "")
			{
				text = "0";
			}
			return text;
		}
		public void getDetailBalancer_Backup_06_1_2011(string sqlQuery)
		{
			try
			{
				DataTable dataTable = new DataTable();
				DataColumn column = new DataColumn("Pid", typeof(string));
				DataColumn column2 = new DataColumn("ProductName", typeof(string));
				DataColumn column3 = new DataColumn("ProductNumberMin", typeof(string));
				DataColumn column4 = new DataColumn("ProductNumberBalancer", typeof(string));
				DataColumn column5 = new DataColumn("ProductNumberMax", typeof(string));
				DataColumn column6 = new DataColumn("ProductUnit", typeof(string));
				dataTable.Columns.Add(column);
				dataTable.Columns.Add(column2);
				dataTable.Columns.Add(column3);
				dataTable.Columns.Add(column4);
				dataTable.Columns.Add(column5);
				dataTable.Columns.Add(column6);
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				if (sqlQuery == "")
				{
					this.DayBalancer = int.Parse(this.txtNumber.Text);
					sqlCommand.CommandText = "SELECT [TabDetailBill].[Pid],[TabDetailBill].[ProductName],[TabDetailBill].[ProductNumber],[TabDetailBill].[ProductUnit] FROM [TabDetailBill],[TabBill] WHERE [TabBill].[WID] = '" + this.currWhID + "' AND [TabDetailBill].[billID] = [TabBill].[ID] AND [TypeInput] IN ('IN1','IN2','IN3') ORDER BY [ProductName]";
				}
				else
				{
					sqlCommand.CommandText = sqlQuery;
				}
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				while (sqlDataReader.Read())
				{
					string sqlQuery2 = "SELECT SUM([TabDetailBill].[ProductNumber]/Rate) AS totalInput FROM [TabDetailBill],[TabBill] WHERE [TabDetailBill].[billID] = [TabBill].[ID] AND [TypeInput] IN ('IN1','IN2','IN3') AND [TabDetailBill].[PID] = " + sqlDataReader["PID"].ToString();
					float num = float.Parse(this.numOutput(sqlDataReader["Pid"].ToString()));
					float num2 = float.Parse(this.numMinBalance(sqlDataReader["Pid"].ToString()));
					float num3 = float.Parse(this.numMaxBalance(sqlDataReader["Pid"].ToString()));
					float num4 = float.Parse(this.numTotalInput(sqlQuery2)) - num;
					if (num4 - num2 <= float.Parse(this.txtNumber.Text))
					{
						if (!this.checkProductNameInDataGridView(sqlDataReader["ProductName"].ToString(), dataTable))
						{
							dataTable.Rows.Add(new object[]
							{
								sqlDataReader["Pid"].ToString(),
								sqlDataReader["ProductName"].ToString(),
								num2.ToString(),
								num4.ToString(),
								num3.ToString(),
								" " + sqlDataReader["ProductUnit"].ToString()
							});
						}
					}
				}
				sqlDataReader.Close();
				sqlConnection.Close();
				sqlConnection.Dispose();
				this.btnPrint.Enabled = true;
				this.objTable = dataTable;
				this.dgvProduct.DataSource = this.objTable;
				if (this.objTable.Rows.Count > 0)
				{
					this.lblWarning.Text = string.Concat(new string[]
					{
						"CÓ ",
						this.dgvProduct.Rows.Count.ToString(),
						" SẢN PHẨM CÓ SỐ LƯỢNG TỒN TRÊN MỨC TỐI THIỂU DƯỚI ",
						this.txtNumber.Text.ToUpper(),
						" SẢN PHẨM"
					});
					this.btnPrint.Enabled = true;
				}
				else
				{
					this.btnPrint.Enabled = false;
				}
			}
			catch
			{
				this.btnPrint.Enabled = false;
				this.objTable = null;
				this.dgvProduct.DataSource = this.objTable;
			}
		}
		private bool checkProductNameInDataGridView(string pName, DataTable objTable)
		{
			bool result = false;
			for (int i = 0; i < objTable.Rows.Count; i++)
			{
				if (objTable.Rows[i]["ProductName"].ToString().ToUpper() == pName.ToUpper())
				{
					result = true;
				}
			}
			return result;
		}
		private string numOutput(string PID)
		{
			string text = "0";
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = sqlConnection.CreateCommand();
			sqlCommand.CommandText = string.Concat(new string[]
			{
				"SELECT ISNULL((SELECT SUM(productNumber/Rate) FROM TabDetailBill WHERE BillID IN (SELECT ID FROM TabBill WHERE [WID] = '",
				this.currWhID,
				"' AND [TypeInput] IN ('OUT1','OUT2','OUT3','OUT4')) AND [PID] = ",
				PID,
				"),0) - ISNULL((SELECT SUM(productNumber) FROM TabDetailBill WHERE BillID IN (SELECT ID FROM TabBill WHERE [WID] = '",
				this.currWhID,
				"' AND [TypeInput] IN ('IN3')) AND [PID] = ",
				PID,
				"),0) AS numOutput"
			});
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					text = sqlDataReader["numOutput"].ToString();
				}
			}
			else
			{
				text = "0";
			}
			sqlDataReader.Close();
			sqlConnection.Close();
			sqlConnection.Dispose();
			if (text.Trim() == "")
			{
				text = "0";
			}
			return text;
		}
		private string numTotalInput(string sqlQuery)
		{
			string text = "0";
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = sqlConnection.CreateCommand();
			sqlCommand.CommandText = sqlQuery;
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					text = sqlDataReader["totalInput"].ToString();
				}
			}
			else
			{
				text = "0";
			}
			sqlDataReader.Close();
			sqlConnection.Close();
			sqlConnection.Dispose();
			if (text.Trim() == "")
			{
				text = "0";
			}
			return text;
		}
		private string numMinBalance(string PID)
		{
			string text = "0";
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = sqlConnection.CreateCommand();
			sqlCommand.CommandText = "SELECT [MinBalance] FROM [TabProducts] WHERE [PID] = " + PID;
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					text = sqlDataReader["MinBalance"].ToString();
				}
			}
			else
			{
				text = "0";
			}
			sqlDataReader.Close();
			sqlConnection.Close();
			sqlConnection.Dispose();
			if (text.Trim() == "")
			{
				text = "0";
			}
			return text;
		}
		private string numMaxBalance(string PID)
		{
			string text = "0";
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = sqlConnection.CreateCommand();
			sqlCommand.CommandText = "SELECT [MaxBalance] FROM [TabProducts] WHERE [PID] = " + PID;
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					text = sqlDataReader["MaxBalance"].ToString();
				}
			}
			else
			{
				text = "0";
			}
			sqlDataReader.Close();
			sqlConnection.Close();
			sqlConnection.Dispose();
			if (text.Trim() == "")
			{
				text = "0";
			}
			return text;
		}
		private void btnSearch_Click(object sender, EventArgs e)
		{
			this.getDetailBalancer("");
		}
		private void resetDataGridView()
		{
			this.objTable = null;
			this.dgvProduct.DataSource = this.objTable;
			this.btnPrint.Enabled = false;
		}
		private void btnPrint_Click(object sender, EventArgs e)
		{
			frmUnderBalancerPrint.objTable = new DataTable();
			frmUnderBalancerView frmUnderBalancerView = new frmUnderBalancerView();
			if (this.cbbParentGID.SelectedValue.ToString() != "0")
			{
				frmUnderBalancerView.productGroup = "Nhóm hàng hoá : " + this.cbbParentGID.Text;
			}
			else
			{
				frmUnderBalancerView.productGroup = "Nhóm hàng hoá : Tất cả";
			}
			frmUnderBalancerPrint.objTable = this.objTable;
			frmUnderBalancerView.ShowDialog();
		}
		private void cbbDayDefault_CheckedChanged(object sender, EventArgs e)
		{
			if (this.cbbDayDefault.Checked)
			{
				this.txtNumber.Enabled = false;
				this.DayBalancer = this.objFunc.getWarningNumberProduct();
				this.txtNumber.Text = this.DayBalancer.ToString();
			}
			else
			{
				this.txtNumber.Enabled = true;
			}
		}
		private void txtSearch_KeyDown(object sender, KeyEventArgs e)
		{
			if (this.txtSearch.Text != "")
			{
				if (e.KeyCode == Keys.Return)
				{
					this.getDetailBalancer("SELECT * FROM [TabTotalBalancer] WHERE [ProductName] LIKE N'%" + this.txtSearch.Text.ToUpper() + "%' ORDER BY [ProductName]");
				}
			}
		}
		private void btnExportToExcel_Click(object sender, EventArgs e)
		{
			try
			{
				frmUnderBalancerPrint.objTable = new DataTable();
				frmUnderBalancerPrint.objTable = this.objTable;
				ActiveReport3 activeReport = new frmUnderBalancerPrint();
				activeReport.Run();
				XlsExport xlsExport = new XlsExport();
				SaveFileDialog saveFileDialog = new SaveFileDialog();
				saveFileDialog.ShowDialog();
				string text = saveFileDialog.FileName;
				if (text != "")
				{
					if (!text.ToUpper().Contains(".XLS"))
					{
						text += ".xls";
					}
					xlsExport.Export(activeReport.Document, text);
					MessageBox.Show("Hệ thống đã hoàn thành việc xuất dữ liệu ra file Excel", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show("Bạn chưa chọn đường dẫn và tên file cần xuất!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}
			}
			catch
			{
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle6 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle7 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle8 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle9 = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmUnderBalancer));
			this.dgvProduct = new DataGridView();
			this.btnClose = new Button();
			this.groupBox1 = new GroupBox();
			this.txtSearch = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.cbbDayDefault = new System.Windows.Forms.CheckBox();
			this.txtNumber = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.cbbParentGID = new ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.btnPrint = new Button();
			this.lblWarning = new System.Windows.Forms.Label();
			this.btnExportToExcel = new Button();
			this.label4 = new System.Windows.Forms.Label();
			this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn4 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn5 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn6 = new DataGridViewTextBoxColumn();
			this.Column2 = new DataGridViewTextBoxColumn();
			this.Column1 = new DataGridViewTextBoxColumn();
			this.Column6 = new DataGridViewTextBoxColumn();
			this.Column4 = new DataGridViewTextBoxColumn();
			this.Column3 = new DataGridViewTextBoxColumn();
			this.Column9 = new DataGridViewTextBoxColumn();
			this.label5 = new System.Windows.Forms.Label();
			((ISupportInitialize)this.dgvProduct).BeginInit();
			this.groupBox1.SuspendLayout();
			base.SuspendLayout();
			this.dgvProduct.AllowUserToAddRows = false;
			this.dgvProduct.AllowUserToDeleteRows = false;
			this.dgvProduct.AllowUserToOrderColumns = true;
			this.dgvProduct.AllowUserToResizeColumns = false;
			this.dgvProduct.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvProduct.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvProduct.BackgroundColor = Color.White;
			this.dgvProduct.BorderStyle = BorderStyle.Fixed3D;
			this.dgvProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
			this.dgvProduct.Columns.AddRange(new DataGridViewColumn[]
			{
				this.Column2,
				this.Column1,
				this.Column6,
				this.Column4,
				this.Column3,
				this.Column9
			});
			this.dgvProduct.Cursor = Cursors.Hand;
			this.dgvProduct.EnableHeadersVisualStyles = false;
			this.dgvProduct.Location = new System.Drawing.Point(7, 112);
			this.dgvProduct.MultiSelect = false;
			this.dgvProduct.Name = "dgvProduct";
			this.dgvProduct.ReadOnly = true;
			this.dgvProduct.RowHeadersVisible = false;
			this.dgvProduct.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvProduct.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvProduct.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvProduct.Size = new Size(886, 450);
			this.dgvProduct.TabIndex = 1;
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.Cursor = Cursors.Hand;
			this.btnClose.FlatAppearance.BorderColor = Color.FromArgb(255, 192, 255);
			this.btnClose.FlatStyle = FlatStyle.Flat;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new System.Drawing.Point(799, 567);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(91, 26);
			this.btnClose.TabIndex = 38;
			this.btnClose.Text = "Thoát [ ESC ]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.groupBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.groupBox1.Controls.Add(this.cbbDayDefault);
			this.groupBox1.Controls.Add(this.label5);
			this.groupBox1.Controls.Add(this.txtSearch);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.txtNumber);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.cbbParentGID);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.groupBox1.Location = new System.Drawing.Point(7, 2);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new Size(886, 83);
			this.groupBox1.TabIndex = 39;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Điều kiện tìm kiếm";
			this.txtSearch.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.txtSearch.BackColor = Color.White;
			this.txtSearch.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.txtSearch.Location = new System.Drawing.Point(698, 21);
			this.txtSearch.Name = "txtSearch";
			this.txtSearch.Size = new Size(180, 21);
			this.txtSearch.TabIndex = 49;
			this.txtSearch.KeyDown += new KeyEventHandler(this.txtSearch_KeyDown);
			this.label2.AutoSize = true;
			this.label2.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.label2.Location = new System.Drawing.Point(582, 24);
			this.label2.Name = "label2";
			this.label2.Size = new Size(112, 15);
			this.label2.TabIndex = 48;
			this.label2.Text = "Tên thuốc - vật tư :";
			this.cbbDayDefault.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.cbbDayDefault.BackColor = Color.White;
			this.cbbDayDefault.Checked = true;
			this.cbbDayDefault.CheckState = CheckState.Checked;
			this.cbbDayDefault.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.cbbDayDefault.Location = new System.Drawing.Point(150, 49);
			this.cbbDayDefault.Name = "cbbDayDefault";
			this.cbbDayDefault.Size = new Size(728, 22);
			this.cbbDayDefault.TabIndex = 47;
			this.cbbDayDefault.Text = "Sử dụng thông số báo cáo mặc định";
			this.cbbDayDefault.UseVisualStyleBackColor = false;
			this.cbbDayDefault.CheckedChanged += new EventHandler(this.cbbDayDefault_CheckedChanged);
			this.txtNumber.BackColor = Color.White;
			this.txtNumber.Enabled = false;
			this.txtNumber.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.txtNumber.Location = new System.Drawing.Point(148, 23);
			this.txtNumber.Name = "txtNumber";
			this.txtNumber.Size = new Size(75, 21);
			this.txtNumber.TabIndex = 46;
			this.txtNumber.Text = "5";
			this.txtNumber.TextAlign = HorizontalAlignment.Center;
			this.label3.AutoSize = true;
			this.label3.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.label3.Location = new System.Drawing.Point(6, 25);
			this.label3.Name = "label3";
			this.label3.Size = new Size(138, 15);
			this.label3.TabIndex = 45;
			this.label3.Text = "Tồn trên mức tối thiểu :";
			this.cbbParentGID.BackColor = Color.White;
			this.cbbParentGID.Cursor = Cursors.Hand;
			this.cbbParentGID.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbParentGID.FlatStyle = FlatStyle.Flat;
			this.cbbParentGID.Font = new Font("Arial", 8.5f);
			this.cbbParentGID.FormattingEnabled = true;
			this.cbbParentGID.Location = new System.Drawing.Point(355, 21);
			this.cbbParentGID.Name = "cbbParentGID";
			this.cbbParentGID.Size = new Size(223, 22);
			this.cbbParentGID.TabIndex = 40;
			this.cbbParentGID.SelectedIndexChanged += new EventHandler(this.cbbParentGID_SelectedIndexChanged);
			this.label1.AutoSize = true;
			this.label1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.label1.Location = new System.Drawing.Point(227, 25);
			this.label1.Name = "label1";
			this.label1.Size = new Size(124, 15);
			this.label1.TabIndex = 41;
			this.label1.Text = "Nhóm thuốc - vật tư :";
			this.btnPrint.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnPrint.Cursor = Cursors.Hand;
			this.btnPrint.Enabled = false;
			this.btnPrint.FlatAppearance.BorderColor = Color.FromArgb(255, 192, 255);
			this.btnPrint.FlatStyle = FlatStyle.Flat;
			this.btnPrint.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnPrint.Location = new System.Drawing.Point(9, 567);
			this.btnPrint.Name = "btnPrint";
			this.btnPrint.Size = new Size(102, 26);
			this.btnPrint.TabIndex = 40;
			this.btnPrint.Text = "Xem và in [ F7 ]";
			this.btnPrint.UseVisualStyleBackColor = true;
			this.btnPrint.Click += new EventHandler(this.btnPrint_Click);
			this.lblWarning.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.lblWarning.BackColor = Color.White;
			this.lblWarning.BorderStyle = BorderStyle.Fixed3D;
			this.lblWarning.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.lblWarning.ForeColor = Color.Red;
			this.lblWarning.Location = new System.Drawing.Point(7, 89);
			this.lblWarning.Name = "lblWarning";
			this.lblWarning.Size = new Size(886, 24);
			this.lblWarning.TabIndex = 43;
			this.lblWarning.Text = "---";
			this.lblWarning.TextAlign = ContentAlignment.MiddleCenter;
			this.btnExportToExcel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnExportToExcel.Enabled = false;
			this.btnExportToExcel.FlatAppearance.BorderColor = Color.FromArgb(255, 192, 255);
			this.btnExportToExcel.FlatStyle = FlatStyle.Flat;
			this.btnExportToExcel.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnExportToExcel.Location = new System.Drawing.Point(114, 567);
			this.btnExportToExcel.Name = "btnExportToExcel";
			this.btnExportToExcel.Size = new Size(102, 26);
			this.btnExportToExcel.TabIndex = 45;
			this.btnExportToExcel.Text = "Xuất file Excel";
			this.btnExportToExcel.UseVisualStyleBackColor = true;
			this.btnExportToExcel.Click += new EventHandler(this.btnExportToExcel_Click);
			this.label4.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.label4.BackColor = Color.White;
			this.label4.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label4.ForeColor = Color.Red;
			this.label4.Location = new System.Drawing.Point(7, 565);
			this.label4.Name = "label4";
			this.label4.Size = new Size(886, 31);
			this.label4.TabIndex = 46;
			this.label4.TextAlign = ContentAlignment.MiddleCenter;
			this.dataGridViewTextBoxColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn1.DataPropertyName = "productName";
			dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle2.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle2.ForeColor = Color.Black;
			this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle2;
			this.dataGridViewTextBoxColumn1.HeaderText = "Sản phẩm";
			this.dataGridViewTextBoxColumn1.MinimumWidth = 100;
			this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
			this.dataGridViewTextBoxColumn2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn2.DataPropertyName = "ProductNumberMin";
			dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle3.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle3.ForeColor = Color.Red;
			this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle3;
			this.dataGridViewTextBoxColumn2.HeaderText = "Tồn tối thiểu";
			this.dataGridViewTextBoxColumn2.MinimumWidth = 100;
			this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
			this.dataGridViewTextBoxColumn3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn3.DataPropertyName = "ProductNumberBalancer";
			dataGridViewCellStyle4.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle4.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			dataGridViewCellStyle4.ForeColor = Color.Blue;
			dataGridViewCellStyle4.Format = "N0";
			dataGridViewCellStyle4.NullValue = null;
			this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle4;
			this.dataGridViewTextBoxColumn3.HeaderText = "Tồn hiện tại";
			this.dataGridViewTextBoxColumn3.MinimumWidth = 120;
			this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
			this.dataGridViewTextBoxColumn3.Width = 120;
			this.dataGridViewTextBoxColumn4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn4.DataPropertyName = "ProductNumberMax";
			dataGridViewCellStyle5.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle5.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle5.ForeColor = Color.Red;
			this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle5;
			this.dataGridViewTextBoxColumn4.HeaderText = "Tồn tối đa";
			this.dataGridViewTextBoxColumn4.MinimumWidth = 100;
			this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
			this.dataGridViewTextBoxColumn5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn5.DataPropertyName = "productUnit";
			this.dataGridViewTextBoxColumn5.HeaderText = "Đơn vị tính";
			this.dataGridViewTextBoxColumn5.MinimumWidth = 150;
			this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
			this.dataGridViewTextBoxColumn5.Width = 150;
			this.dataGridViewTextBoxColumn6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn6.DataPropertyName = "Pid";
			this.dataGridViewTextBoxColumn6.HeaderText = "Mã sản phẩm";
			this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
			this.dataGridViewTextBoxColumn6.Visible = false;
			this.Column2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.Column2.DataPropertyName = "productName";
			dataGridViewCellStyle6.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle6.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle6.ForeColor = Color.Black;
			this.Column2.DefaultCellStyle = dataGridViewCellStyle6;
			this.Column2.HeaderText = "Sản phẩm";
			this.Column2.MinimumWidth = 100;
			this.Column2.Name = "Column2";
			this.Column2.ReadOnly = true;
			this.Column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column1.DataPropertyName = "ProductNumberMin";
			dataGridViewCellStyle7.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle7.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle7.ForeColor = Color.Red;
			this.Column1.DefaultCellStyle = dataGridViewCellStyle7;
			this.Column1.HeaderText = "Tồn tối thiểu";
			this.Column1.MinimumWidth = 100;
			this.Column1.Name = "Column1";
			this.Column1.ReadOnly = true;
			this.Column6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column6.DataPropertyName = "ProductNumberBalancer";
			dataGridViewCellStyle8.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle8.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			dataGridViewCellStyle8.ForeColor = Color.Blue;
			dataGridViewCellStyle8.Format = "N0";
			dataGridViewCellStyle8.NullValue = null;
			this.Column6.DefaultCellStyle = dataGridViewCellStyle8;
			this.Column6.HeaderText = "Tồn hiện tại";
			this.Column6.MinimumWidth = 120;
			this.Column6.Name = "Column6";
			this.Column6.ReadOnly = true;
			this.Column6.Width = 120;
			this.Column4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column4.DataPropertyName = "ProductNumberMax";
			dataGridViewCellStyle9.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle9.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle9.ForeColor = Color.Red;
			this.Column4.DefaultCellStyle = dataGridViewCellStyle9;
			this.Column4.HeaderText = "Tồn tối đa";
			this.Column4.MinimumWidth = 100;
			this.Column4.Name = "Column4";
			this.Column4.ReadOnly = true;
			this.Column3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column3.DataPropertyName = "productUnit";
			this.Column3.HeaderText = "Đơn vị tính";
			this.Column3.MinimumWidth = 150;
			this.Column3.Name = "Column3";
			this.Column3.ReadOnly = true;
			this.Column3.Width = 150;
			this.Column9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column9.DataPropertyName = "Pid";
			this.Column9.HeaderText = "Mã sản phẩm";
			this.Column9.Name = "Column9";
			this.Column9.ReadOnly = true;
			this.Column9.Visible = false;
			this.label5.BackColor = Color.White;
			this.label5.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.label5.Location = new System.Drawing.Point(145, 49);
			this.label5.Name = "label5";
			this.label5.Size = new Size(64, 22);
			this.label5.TabIndex = 50;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.btnExportToExcel);
			base.Controls.Add(this.lblWarning);
			base.Controls.Add(this.btnPrint);
			base.Controls.Add(this.groupBox1);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.dgvProduct);
			base.Controls.Add(this.label4);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.Name = "frmUnderBalancer";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "SẢN PHẨM SẮP ĐẾN SỐ LƯỢNG TỐI THIỂU";
			base.WindowState = FormWindowState.Maximized;
			base.Load += new EventHandler(this.frmInput_Load);
			base.KeyDown += new KeyEventHandler(this.frmInput_KeyDown);
			((ISupportInitialize)this.dgvProduct).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.groupBox1.PerformLayout();
			base.ResumeLayout(false);
		}
	}
}
